﻿<%@ WebHandler Language="C#" Class="HotMapHandler" %>

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Business.Common;
using Business.Map;
using WF_Business;

public class HotMapHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write(GetJsonStr());
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    private static string GetJsonStr()
    {
        var dtTemp = GetStatData();
        var list = new List<HotMap>();
        dtTemp.Rows.Cast<DataRow>().ToList().ForEach(row => list.Add(new HotMap
        {
            PointX = row["pointx"].ToString(),
            PointY = row["pointy"].ToString(),
            Count = row["count"].ToString()
        }));
        return list.T2Json();
    }

    private static DataTable GetStatData()
    {
        var ida = SysParams.OAConnection();
        var dtTemp = new DataTable();
        const string strSql = " SELECT pointx,pointy,count FROM TB_HOTMAPSTAT ";
        ida.RunSql(strSql, out dtTemp);
        return dtTemp;
    }
}